﻿using Md.Api.Model;
using Md.Api.Model.Manage.SysPost.Request;
using Md.Api.Service.Manage.SysPost;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 系统岗位
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/system/post")]
public class SysPostController : ControllerBase
{
    /// <summary>
    /// 通过岗位编号删除系统岗位服务
    /// </summary>
    public DeleteSysPostByPostIdService deleteSysPostByPostIdService { get; set; }
    /// <summary>
    /// 通过岗位编号删除系统岗位
    /// </summary>
    /// <param name="postIds">岗位编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{postIds}")]
    public async Task<ResponseMessageModel> DeleteSysPostByPostId(string postIds, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteSysPostByPostIdModel();

        model.PostIds = postIds;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteSysPostByPostIdService.Execute(model));
    }

    /// <summary>
    /// 添加系统岗位服务
    /// </summary>
    public InsertSysPostService insertSysPostService { get; set; }
    /// <summary>
    /// 添加系统岗位
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertSysPost([FromBody] RequestInsertSysPostModel model)
    {
        return await Task.Run(() => insertSysPostService.Execute(model));
    }

    /// <summary>
    /// 通过岗位编号更新系统岗位服务
    /// </summary>
    public UpdateSysPostByPostIdService updateSysPostByPostIdService { get; set; }
    /// <summary>
    /// 通过岗位编号更新系统岗位
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateSysPostByPostId([FromBody] RequestUpdateSysPostByPostIdModel model)
    {
        return await Task.Run(() => updateSysPostByPostIdService.Execute(model));
    }

    /// <summary>
    /// 通过岗位编号获取系统岗位信息服务
    /// </summary>
    public GetSysPostByPostIdService getSysPostByPostIdService { get; set; }
    /// <summary>
    /// 通过岗位编号获取系统岗位信息
    /// </summary>
    /// <param name="postId">岗位编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{postId}")]
    public async Task<ResponseMessageModel> GetSysPostByPostId(long postId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetSysPostByPostIdModel();

        model.PostId = postId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getSysPostByPostIdService.Execute(model));
    }

    /// <summary>
    /// 获取系统岗位列表服务
    /// </summary>
    public GetSysPostListService getSysPostListService { get; set; }
    /// <summary>
    /// 获取系统岗位列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetSysPostList([FromBody] RequestGetSysPostListModel model)
    {
        return await Task.Run(() => getSysPostListService.Execute(model));
    }

    /// <summary>
    /// 分页获取系统岗位列表服务
    /// </summary>
    public GetSysPostPagetListService getSysPostPagetListService { get; set; }
    /// <summary>
    /// 分页获取系统岗位列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetSysPostPagetList([FromBody] RequestGetSysPostPagetListModel model)
    {
        return await Task.Run(() => getSysPostPagetListService.Execute(model));
    }
}

